package com.azzcs.lifecycle;

import java.util.List;

/**
 * @Author: wzg
 * @Date: 2021/1/7 下午2:55
 */
public interface Lifecycle {
    // 13个状态常量值
    String BEFORE_INIT_EVENT = "before_init";
    String AFTER_INIT_EVENT = "after_init";
    String START_EVENT = "start";
    String BEFORE_START_EVENT = "before_start";
    String AFTER_START_EVENT = "after_start";
    String STOP_EVENT = "stop";
    String BEFORE_STOP_EVENT = "before_stop";
    String AFTER_STOP_EVENT = "after_stop";
    String AFTER_DESTROY_EVENT = "after_destroy";
    String BEFORE_DESTROY_EVENT = "before_destroy";
    String PERIODIC_EVENT = "periodic";
    String CONFIGURE_START_EVENT = "configure_start";
    String CONFIGURE_STOP_EVENT = "configure_stop";

    // 3个监听器方法
    void addLifecycleListener(LifecycleListener listener);

    List<LifecycleListener> findLifecycleListeners();

    void removeLifecycleListener(LifecycleListener listener);

    // 4个生命周期方法
    void init();

    void start();

    void stop();

    void destroy();

    // 2个当前状态方法
    LifecycleState getState();

    String getStateName();
}
